import Vue from 'vue'
import VueRouter from 'vue-router'
import User from '@/views/user/index.vue'
import Employee from '@/views/employee'
// import Admin from '@/views/admin'
import Page404 from '@/views/404.vue'
import userSecondRouter from './Modules/user'
import employeeRouter from './Modules/employee'
import adminRouter from './Modules/admin'
// import UserLogin from '@/views/Login/UserLogin.vue'
// import UserRegistry from '@/views/registry/UserRegistry.vue'
// import UserDetails from '@/views/user/UserDetails.vue'
// import UserPassword from '@/views/user/UserPassword.vue'
Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    // 用户路由
    {
      path: '/',
      component: User,
      redirect: '/user',
      children: [
        ...userSecondRouter
      ]
    },
    // 员工页面路由
    {
      path: '/back',
      component: Employee,
      children: [
        ...employeeRouter
      ]
    },
    // 管理员页面路由
    {
      path: '/admin',
      component: Employee,
      children: [
        ...adminRouter
      ]
    },
    {
      path: '/404',
      component: Page404
    }
  ]
})

// const whiteList = ['/404', '/login', '/user/userHome', '/user/onlineReserve', '/registry', '/manage/login']
// router.beforeEach((to, from, next) => {
//   // console.log('请求路径:', to.fullPath)
//   console.log('路由路径:', to.path)
//   // 存在token
//   if (store.getters.token) {
//     if (to.path === 'login') {
//       next('/')
//     } else {
//       next()
//     }
//   } else {
//     // 不存在token
//     console.log(to.path)
//     if (whiteList.includes(to.path)) {
//       next()
//     } else {
//       next('/login')
//     }
//   }
// })

export default router
